Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/settings/src/androidMain/kotlin/org/meshtastic/feature/settings/tak/TakPermissionUtil.kt renovate/fastlane-2.x-lockfile (423f9d44) Text, 4.99 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.settings.tak

Tff7b72import T7ee787androidx.compose.runtime.Composable
Tff7b72import T7ee787androidx.compose.runtime.LaunchedEffect
Tff7b72import T7ee787androidx.compose.runtime.getValue
Tff7b72import T7ee787androidx.compose.runtime.mutableStateOf
Tff7b72import T7ee787androidx.compose.runtime.remember
Tff7b72import T7ee787androidx.compose.runtime.rememberUpdatedState
Tff7b72import T7ee787androidx.compose.runtime.setValue
Tff7b72import T7ee787org.meshtastic.core.resources.Res
Tff7b72import T7ee787org.meshtastic.core.resources.local_network_permission
Tff7b72import T7ee787org.meshtastic.core.resources.local_network_permission_rationale
Tff7b72import T7ee787org.meshtastic.core.resources.open_settings
Tff7b72import T7ee787org.meshtastic.core.resources.tak_server_permission_blocked
Tff7b72import T7ee787org.meshtastic.core.ui.component.MeshtasticDialog
Tff7b72import T7ee787org.meshtastic.core.ui.component.PermissionRationaleDialog
Tff7b72import T7ee787org.meshtastic.core.ui.icon.AppSettingsAlt
Tff7b72import T7ee787org.meshtastic.core.ui.icon.Language
Tff7b72import T7ee787org.meshtastic.core.ui.icon.MeshtasticIcons
Tff7b72import T7ee787org.meshtastic.core.ui.util.PermissionGateAction
Tff7b72import T7ee787org.meshtastic.core.ui.util.permissionGateAction
Tff7b72import T7ee787org.meshtastic.core.ui.util.rememberLocalNetworkPermissionState

Tf0883e@Composable
Tff7b72actual Tff7b72fun Td2a8ffTakPermissionHandlerTb4b4b4(Te6edf3isTakServerEnabledTb4b4b4: Tffa657BooleanTb4b4b4, Te6edf3onPermissionResultTb4b4b4: Tb4b4b4(Tffa657BooleanTb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4) Tb4b4b4{
T8b949e// ACCESS_LOCAL_NETWORK (Android 17 / API 37+) is required for the TAK Server's localhost socket binding
T8b949e// (127.0.0.1:8087). It is also required for NSD/mDNS device discovery when targetSdk >= 37 and is requested from
T8b949e// the Connections screen, so it will usually already be granted by the time the user enables TAK. This composable
T8b949e// handles the standalone case — a user who opens TAK settings before ever tapping the network-scan toggle.
Tff7b72val Te6edf3permission Tff7b72= Te6edf3rememberLocalNetworkPermissionStateTb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3currentOnPermissionResult Tff7b72by Te6edf3rememberUpdatedStateTb4b4b4(Te6edf3onPermissionResultTb4b4b4)

Tff7b72var Te6edf3showRationale Tff7b72by Te6edf3remember Tb4b4b4{ Te6edf3mutableStateOfTb4b4b4(Tff7b72falseTb4b4b4) Tb4b4b4}
Tff7b72var Te6edf3showBlocked Tff7b72by Te6edf3remember Tb4b4b4{ Te6edf3mutableStateOfTb4b4b4(Tff7b72falseTb4b4b4) Tb4b4b4}

T8b949e// The launcher must run as a post-composition side effect — invoking it directly in the composition body crashes
T8b949e// with "Launcher has not been initialized". Keying on the status enum re-runs only on real transitions.
Te6edf3LaunchedEffectTb4b4b4(Te6edf3isTakServerEnabledTb4b4b4, Te6edf3permissionTb4b4b4.Te6edf3statusTb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Tff7b72!Te6edf3isTakServerEnabledTb4b4b4) Tff7b72returnTf0883e@LaunchedEffect
Tff7b72when Tb4b4b4(Te6edf3permissionGateActionTb4b4b4(Te6edf3permissionTb4b4b4.Te6edf3statusTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3PermissionGateActionTb4b4b4.Te6edf3PROCEED Tff7b72-Tff7b72> Te6edf3currentOnPermissionResultTb4b4b4(Tff7b72trueTb4b4b4)

Te6edf3PermissionGateActionTb4b4b4.Te6edf3REQUEST Tff7b72-Tff7b72> Te6edf3permissionTb4b4b4.Te6edf3requestTb4b4b4(Tb4b4b4)

T8b949e// Previously this disabled the server outright, same as a permanent denial. It is not the same: the
T8b949e// system will still prompt here, and the user has been given no reason to answer differently than last
T8b949e// time. Explain first, then let them decide.
Te6edf3PermissionGateActionTb4b4b4.Te6edf3SHOW_RATIONALE Tff7b72-Tff7b72> Te6edf3showRationale Tff7b72= Tff7b72true

T8b949e// Still disables the server — it genuinely cannot bind its socket — but no longer silently. Turning a
T8b949e// feature off and saying nothing leaves the user with a switch that will not stay on and no way to learn
T8b949e// why, which is exactly the dead end this whole change set is about.
Te6edf3PermissionGateActionTb4b4b4.Te6edf3OPEN_SETTINGS Tff7b72-Tff7b72> Tb4b4b4{
Te6edf3currentOnPermissionResultTb4b4b4(Tff7b72falseTb4b4b4)
Te6edf3showBlocked Tff7b72= Tff7b72true
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Tff7b72if Tb4b4b4(Te6edf3showRationaleTb4b4b4) Tb4b4b4{
Te6edf3PermissionRationaleDialogTb4b4b4(
Te6edf3titleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3local_network_permissionTb4b4b4,
Te6edf3rationaleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3local_network_permission_rationaleTb4b4b4,
Te6edf3icon Tff7b72= Te6edf3MeshtasticIconsTb4b4b4.Te6edf3LanguageTb4b4b4,
Te6edf3onConfirm Tff7b72= Tb4b4b4{
Te6edf3showRationale Tff7b72= Tff7b72false
Te6edf3permissionTb4b4b4.Te6edf3requestTb4b4b4(Tb4b4b4)
Tb4b4b4}Tb4b4b4,
Te6edf3onDismiss Tff7b72= Tb4b4b4{
Te6edf3showRationale Tff7b72= Tff7b72false
Te6edf3currentOnPermissionResultTb4b4b4(Tff7b72falseTb4b4b4)
Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}

Tff7b72if Tb4b4b4(Te6edf3showBlockedTb4b4b4) Tb4b4b4{
Te6edf3MeshtasticDialogTb4b4b4(
Te6edf3titleRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3local_network_permissionTb4b4b4,
Te6edf3messageRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3tak_server_permission_blockedTb4b4b4,
Te6edf3icon Tff7b72= Te6edf3MeshtasticIconsTb4b4b4.Te6edf3AppSettingsAltTb4b4b4,
Te6edf3confirmTextRes Tff7b72= Te6edf3ResTb4b4b4.Te6edf3stringTb4b4b4.Te6edf3open_settingsTb4b4b4,
Te6edf3onConfirm Tff7b72= Tb4b4b4{
Te6edf3showBlocked Tff7b72= Tff7b72false
Te6edf3permissionTb4b4b4.Te6edf3openAppSettingsTb4b4b4(Tb4b4b4)
Tb4b4b4}Tb4b4b4,
Te6edf3onDismiss Tff7b72= Tb4b4b4{ Te6edf3showBlocked Tff7b72= Tff7b72false Tb4b4b4}Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.4 - Generated in 0.03s